/**
 * DCMotor
 *
 * Authors: Bruna and Bruno
 * Date: Jun, 22 2012
 **/

#ifndef DCMotor_h
#define DCMotor_h

#include <Arduino.h>

class DCMotor {
    public:
        DCMotor(int _kp, float _kd, float _ki);
        void begin();
        void forward();
        void stop();
        void left();
        void right();
        
    private:
        int left_speed;
        int right_speed;
    
        long last_check_inst;
    
        void setMotorVelocity();    
        void doPID();
        
        int kp; //PID proportional gain constant 
        float kd; //PID derivative gain constant
        float ki; //PID intergral gain constant
        
        int preverrorl; //left motor previous error
        int preverrorr; //right motor previous error
        int Ierrorl; //left motor intergral error
        int Ierrorr; //right motor intergral error
        
        static int count_left_ticks;
        static int count_right_ticks;
        
        static void inc_left_ticks();
        static void inc_right_ticks();
};
#endif